﻿using System.Drawing.Imaging;

namespace ScreenPrint
{
    public class Class1
    {
        public static void Main()
        {
            // 获取屏幕尺寸
            Rectangle bounds = Screen.GetBounds(Point.Empty);
            // 创建一个与屏幕尺寸相同的Bitmap对象
            using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
            {
                // 创建一个Graphics对象用于绘制
                using (Graphics g = Graphics.FromImage(bitmap))
                {
                    // 将屏幕内容绘制到bitmap上
                    g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
                }

                // 保存图片到桌面
                string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                string screenshotPath = Path.Combine(desktopPath, "Screenshot.png");
                bitmap.Save(screenshotPath, ImageFormat.Png);
            }
            Console.WriteLine("截图已保存到桌面");
        }
    }
}
